<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Object静态方法</title>
</head>

<body>
    <script>
        const student = {
            studentName: '张三',
            gender: '男'
        }

        // Object.keys() 获取所有键，以数组的形式返回
        console.log(Object.keys(student)); // [studentName, gender]

        // Object.values() 获取所有值，以数组的形式返回
        console.log(Object.values(student)); // ['张三', '男']

        // Object.assign(新对象，旧对象)
        const newStudent = {}
        Object.assign(newStudent, student)

        // 可用来添加属性 Object.assign(对象，新增的属性)
        Object.assign(student, { age: 18 })
        console.log(Object.keys(student)); // ['studentName', 'gender', 'age']

    </script>
</body>

</html>